﻿using UnityEngine;
using System.Collections;

public class FollowRole : MonoBehaviour {
	public Transform Target;
	public float smoothTime = 0.05f;
	private Vector3 velocity = Vector3.zero;
	public Vector3 Move;
	public Vector3 offset;
	public bool UseSmoothTime = false;
//	void FixedUpdate (){
	void LateUpdate (){
		if (Target == null)
			return;
		Vector3 targetpos;
		targetpos = Target.transform.position + offset;
		if (UseSmoothTime) {
			Move = Vector3.SmoothDamp (transform.position,targetpos , ref velocity, smoothTime*Time.deltaTime);
//			Move.z = Target.position.z;
		} else
			Move = Target.transform.position;
		transform.position = Move;
	}
}
